package client;

import bean.*;
import dao.search.MoneyMessageSearchDao;
import service.menu.ManagerMenuService;
import service.menu.SuperManagerMenuService;
import util.dbutil.*;

import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class SuperManagerMnueClient {
    /**
     * 房间管理菜单
     **/
    public void roomManageList() throws SQLException, ParseException {
        Scanner sc = new Scanner(System.in);
        LoginRoom lr = new LoginRoom();
        Room room = new Room();
        System.out.println("1.房间录入\n2.房间修改\n0.返回上层菜单\n请选择：");
        int choice = sc.nextInt();
        switch (choice){
            case 1 :
                //房间录入
                System.out.println("请输入id：");
                int a = sc.nextInt();
                room.setId(a);
                System.out.println("请输入房间号：");
                int b = sc.nextInt();
                room.setrNumber(b);
                System.out.println("请输入性别：");
                String c = sc.next();
                room.setSex(c);
                System.out.println("请输入入住人数：");
                int d = sc.nextInt();
                room.setInNumber(d);
                System.out.println("请输入押金：");
                int e = sc.nextInt();
                room.setMoney(e);
                lr.insertRoom(room);
                System.out.println("输入0返回上一层菜单");
                int z = sc.nextInt();
                if (0 == z){
                    roomManageList();
                }


                break;
            case 2:
                //房间修改
                System.out.println("请输入要修改的学号：");
                int a1 = sc.nextInt();
                room.setrNumber(a1);
                System.out.println("请输入修改后性别：");
                String c1 = sc.next();
                room.setSex(c1);
                System.out.println("请输入修改后入住人数：");
                int d1 = sc.nextInt();
                room.setInNumber(d1);
                System.out.println("请输入修改后押金：");
                int e1 = sc.nextInt();
                room.setMoney(e1);
                lr.updateRoom(room);
                System.out.println("输入0返回上一层菜单");
                int y = sc.nextInt();
                if (0 == y){
                    roomManageList();
                }
                break;
            default:
                SuperManagerMenuService smms = new SuperManagerMenuService();
                smms.superManagerSys();
        }
    }
    /**
     * 班级管理菜单
     **/
    public void classMnanageList() throws SQLException, ParseException {
        Scanner sc = new Scanner(System.in);
        LoginClass lc = new LoginClass();
        Classer classer = new Classer();
        System.out.println("1.添加班级\n2.修改班级\n0.返回上层菜单\n请选择：");
        int choice = sc.nextInt();
        switch (choice){
            case 1:
                //添加班级
                System.out.println("请输入id：");
                int a = sc.nextInt();
                classer.setId(a);
                System.out.println("请输入班级名称：");
                String b = sc.next();
                classer.setClassName(b);
                System.out.println("请输入班级号");
                int c = sc.nextInt();
                classer.setcNumber(c);
                lc.insertClass(classer);

                System.out.println("输入0返回上一层菜单");
                int z = sc.nextInt();
                if (0 == z){
                    classMnanageList();
                }
                break;
            case 2:
                //修改班级
                System.out.println("请输入要修改的班级id：");
                int a1 = sc.nextInt();
                classer.setId(a1);
                System.out.println("请输入班级名称：");
                String b1 = sc.next();
                classer.setClassName(b1);
                System.out.println("请输入班级号");
                int c1 = sc.nextInt();
                classer.setcNumber(c1);
                lc.updateClass(classer);

                System.out.println("输入0返回上一层菜单");
                int y = sc.nextInt();
                if (0 == y) {
                    classMnanageList();
                }
                break;
            default:
                SuperManagerMenuService smms = new SuperManagerMenuService();
                smms.superManagerSys();
                break;

        }
    }
    /**
     * 住宿管理菜单
     * */
    public void stayMnanageList() throws SQLException, ParseException {
        Scanner sc = new Scanner(System.in);
        LoginStudent ls = new LoginStudent();
        LoginBed lb = new LoginBed();
        LoginChangeRoom lcr = new LoginChangeRoom();
        LoginInCheck li = new LoginInCheck();
        LoginOutRoom lor = new LoginOutRoom();
        LoginStay lt = new LoginStay();


        Student student = new Student();
        Bed bed = new Bed();
        InCheck inCheck = new InCheck();
        ChangeRoom changeRoom = new ChangeRoom();
        OutRoom outRoom = new OutRoom();


        Date date = new Date();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

        System.out.println("1.办理入住\n2.调换房间\n3.办理退宿\n4.入住修改\n0.返回上层菜单\n请选择：");
        int choice = sc.nextInt();
        switch (choice){
            case 1:
                //办理入住
                System.out.println("请输入学员编号：");
                int a = sc.nextInt();
                student.setsNumber(a);
                System.out.println("请输入学员姓名：");
                String b = sc.next();
                student.setName(b);
                System.out.println("请输入学员性别");
                String c = sc.next();
                student.setSex(c);
                System.out.println("请输入学员房间号");
                int d = sc.nextInt();
                student.setSrNumber(d);
                System.out.println("请输入学员班级");
                int e = sc.nextInt();
                student.setScNumber(e);
                System.out.println("请输入学员联系电话：");
                int z =sc.nextInt();
                student.setTel(z);
                System.out.println("请输入床位号");
                int f = sc.nextInt();
                bed.setbNumber(f);
                try {
                    System.out.println("请输入入住时间");
                    String g = sc.next();
                    Date gg = df.parse(g);
                    inCheck.setInTime(gg);
                    System.out.println("请输入退宿时间");
                    String h = sc.next();
                    Date hh = df.parse(h);
                    inCheck.setOutTime(hh);
                } catch (ParseException parseException) {
                    parseException.printStackTrace();
                }
                System.out.println("请输入押金：");
                int l = sc.nextInt();
                inCheck.setMoney(l);
                System.out.println("请输入应缴费用：");
                int m = sc.nextInt();
                inCheck.setGiMoney(m);
                System.out.println("请输入实缴费用：");
                int n = sc.nextInt();
                inCheck.setAcMoney(n);
                System.out.println("请输入钥匙是否领取：");
                String o = sc.next();
                inCheck.setKey(o);

                ls.insertStudent(student);
                lb.insertBed(bed);
                li.insertInCheck(inCheck);

                System.out.println("输入0返回上一层菜单");
                int y = sc.nextInt();
                if (0 == y) {
                    stayMnanageList();
                }

                break;
            case 2:
                //调换房间
                System.out.println("请输入学员编号：");
                int a1 =sc.nextInt();
                changeRoom.setCrsNumber(a1);
                student.setsNumber(a1);
                System.out.println("请输入学员姓名：");
                String b1 = sc.next();
                changeRoom.setCrsName(b1);
                System.out.println("请输入学员原房间号：");
                int c1 = sc.nextInt();
                changeRoom.setCrurNumber(c1);
                System.out.println("请输入学员原床位号：");
                int d1 = sc.nextInt();
                changeRoom.setCrubNumber(d1);
                System.out.println("请输入学员新房间号：");
                int f1 = sc.nextInt();
                changeRoom.setCrnrNumber(f1);
                student.setSrNumber(f1);
                System.out.println("请输入学员新床位号：");
                int g1 = sc.nextInt();
                changeRoom.setCrnbNumber(g1);
                student.setSbNumber(g1);

                lcr.insertChangeRoom(changeRoom);
                lcr.updateStudent(student);

                System.out.println("输入0返回上一层菜单");
                int y1 = sc.nextInt();
                if (0 == y1) {
                    stayMnanageList();
                }

                break;
            case 3:
                //办理退宿
                System.out.println("请输入退宿学生学号：");
                int a2 = sc.nextInt();
                outRoom.setOrsNumber(a2);
                System.out.println("请输入退宿学生姓名：");
                String b2 = sc.next();
                outRoom.setOrsName(b2);
                System.out.println("请输入退宿学生联系电话：");
                int c2 = sc.nextInt();
                outRoom.setOrsTel(c2);
                System.out.println("请输入退宿学生退宿原因：");
                String d2 = sc.next();
                outRoom.setReason(d2);
                try {
                    System.out.println("请输入退宿学生退宿时间：");
                    String e2 = sc.next();
                    Date ee2 = df.parse(e2);
                    outRoom.setOrOutTime(ee2);
                } catch (ParseException parseException) {
                    parseException.printStackTrace();
                }
                System.out.println("请输入退宿学生应缴费用：");
                int f2 = sc.nextInt();
                outRoom.setOrgiMoney(f2);
                System.out.println("请输入退宿学生实缴费用：");
                int g2 = sc.nextInt();
                outRoom.setOracMoney(g2);
                System.out.println("请输入退宿学生退还费用：");
                int h2 = sc.nextInt();
                outRoom.setBackMoney(h2);

                lor.insertOutRoom(outRoom);

                System.out.println("输入0返回上一层菜单");
                int y2 = sc.nextInt();
                if (0 == y2) {
                    stayMnanageList();
                }
                break;

            case 4:
                //入住修改
                System.out.println("请输入需要修改的学生的学号：");
                int a3 = sc.nextInt();
                student.setsNumber(a3);
                System.out.println("请输入修改的学生的姓名");
                String b3 = sc.next();
                student.setName(b3);
                System.out.println("请输入修改的学生的联系电话：");
                int d3 = sc.nextInt();
                student.setTel(d3);
                System.out.println("请输入修改的学生的要是领取状态：");
                String c3 = sc.next();
                lt.updateStudent(student);

                System.out.println("输入0返回上一层菜单");
                int y3 = sc.nextInt();
                if (0 == y3) {
                    stayMnanageList();
                }
                break;

            default:
                SuperManagerMenuService smms = new SuperManagerMenuService();
                smms.superManagerSys();
                break;

        }
    }

    /**
     * 费用管理菜单
     **/
    public void moneyMnanageList() throws SQLException, ParseException {
        Scanner sc = new Scanner(System.in);
        LoginGiveMoney lgm = new LoginGiveMoney();
        MoneyMessageSearchDao mmsd = new MoneyMessageSearchDao();
        GiveMoney giveMoney = new GiveMoney();
        Date date = new Date();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

        System.out.println("1.费用缴纳\n2.费用查询\n0.返回上层菜单\n请选择：");
        int choice = sc.nextInt();
        switch (choice){
            case 1:
                //费用缴纳
                System.out.println("请输入学员编号：");
                int a = sc.nextInt();
                giveMoney.setGmsNumber(a);
                System.out.println("请输入学员姓名：");
                String b = sc.next();
                giveMoney.setGmsName(b);
                System.out.println("请输入学院班级");
                int c = sc.nextInt();
                giveMoney.setGmsCNumber(c);
                System.out.println("请输入联系电话");
                int d = sc.nextInt();
                giveMoney.setGmsTel(d);
                try {
                    System.out.println("请输入学员入住日期：");
                    String e = sc.next();
                    Date ee = df.parse(e);
                    giveMoney.setGmInTime(ee);
                } catch (ParseException parseException) {
                    parseException.printStackTrace();
                }
                System.out.println("请输入应缴费用");
                int f = sc.nextInt();
                giveMoney.setGmgiMoney(f);
                System.out.println("请输入实缴费用");
                int g = sc.nextInt();
                giveMoney.setGmacMoney(g);
                System.out.println("请输入费用差");
                int h = sc.nextInt();
                giveMoney.setMoreMoney(h);

                lgm.insertGiveMoney(giveMoney);

                System.out.println("输入0返回上一层菜单");
                int y = sc.nextInt();
                if (0 == y) {
                    moneyMnanageList();
                }


                break;
            case 2:
                //费用查询
                int a1 = mmsd.allMoney();
                int a2 = mmsd.readyMoney()*150;
                int a3 = a2 -a1;

                System.out.println("目前已入住学员的总费用情况:");
                System.out.println("已缴费用为："+a1);
                System.out.println("未缴费用为："+a3);
                System.out.println("费用差为："+a3);

                System.out.println("输入0返回上一层菜单");
                int y1 = sc.nextInt();
                if (0 == y1) {
                    moneyMnanageList();
                }


                break;
            default:
                SuperManagerMenuService smms = new SuperManagerMenuService();
                smms.superManagerSys();
                break;

        }
    }
}
